#ifndef HTMLLABELS
#define HTMLLABELS

#include <iostream>
#include <string>
#include <vector>
#include "Defines.cpp"

class ResponseHeader
{
private:
    std::string _contentTypeLine = "";
    std::string _contentLengthLine = "";

public:
    void SetContentType(std::string contentType)
    {
        _contentTypeLine = "Content-Type:" + contentType + "\r\n";
    }
    void SetContentLength(long length)
    {
        _contentLengthLine = "Content-Length:" + std::to_string(length) + "\r\n";
    }
    std::string GetString()
    {
        // HTTP/1.1 200 OK\r\n;
        // Server:Httpd/1.1\r\n;
        // Content-Type:text/html\r\n
        // Content-Length:1024\r\n
        // \r\n
        std::string ret = "HTTP/1.1 200 OK\r\n";
        ret += "Server:Httpd/1.1\r\n";
        ret += _contentTypeLine;
        ret += _contentLengthLine;
        ret += "\r\n";
        return ret;
    }
};

class Label_PairDefault
{
private:
    std::string _name;
    std::string _content = "";
    std::vector<std::string> _attrs;

public:
    Label_PairDefault(std::string labelName)
    {
        _name = labelName;
    }

    void SetContent(std::string content)
    {
        _content = content;
    }

    void AddAttr(std::string name, std::string value)
    {
        _attrs.push_back(" " + name + "=\"" + value + "\"");
    }

    std::string GetString()
    {
        // <name attr1="value1" attr2="value2">content</name>
        std::string ret = "<" + _name;
        for (int i = 0; i < _attrs.size(); i++)
        {
            ret += _attrs[i];
        }
        ret += ">";
        ret += _content;
        ret += "</" + _name + ">";
        return ret;
    }
};

class Label_SingleDefault
{
private:
    std::string _name;
    std::vector<std::string> _attrs;

public:
    Label_SingleDefault(std::string labelName)
    {
        _name = labelName;
    }

    void AddAttr(std::string name, std::string value)
    {
        _attrs.push_back(" " + name + "=\"" + value + "\"");
    }

    std::string GetString()
    {
        // <name attr1="value1" attr2="value2">
        std::string ret = "<" + _name;
        for (int i = 0; i < _attrs.size(); i++)
        {
            ret += _attrs[i];
        }
        ret += ">";
        return ret;
    }
};

#endif